package com.onlineclass.backstagemanagement.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@Controller
@RequestMapping("/config")
@RefreshScope
public class NacosConfigController {

    @Value("#{'${teacherLeft:a}'.split(',')}")
    private List<String> teacherLeft;

    @Value("#{'${adminLeft:b}'.split(',')}")
    private List<String> adminLeft;


    @RequestMapping(value = "/getLeft", method = GET)
    @ResponseBody
    public String getLeft() {
        //TODO 判断session中的角色，选择放入的left（techerLeft还是adminLeft）
        return "";
    }


//手动增加配置或修改配置
//    @RequestMapping(value = "/update", method = GET)
//    @ResponseBody
//    public String update(){
//        Map<String,String> map = new HashMap<>();
//        map.put("dataId","nacos.example");
//        map.put("type","properties");
//        map.put("content","contentTest=true11");
//        map.put("group","com.alibaba.nacos");
//
//        return HttpClientUtil.doPost("http://127.0.0.1:8848/nacos/v1/cs/configs",map,"utf8");
//    }
//
//
//    @RequestMapping(value = "/getR.emote", method = GET)
//    @ResponseBody
//    public String getRemote(){
//        Map<String,String> map = new HashMap<>();
//        map.put("dataId","nacos.example");
//        map.put("type","properties");
//        map.put("group","com.alibaba.nacos");
//
//        return HttpClientUtil.doGet("http://127.0.0.1:8848/nacos/v1/cs/configs",map,"utf8");
//    }



}
